<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		*{
			padding: 0px;
			margin: 0px;
			list-style: none;
		}
		.box{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
			margin: 10px;
			float: left;
			font-size: 30px;
			color: #fff;
		}
	</style>
	<script type="text/javascript">
		
		window.onload= function () {
			box = document.getElementsByClassName('box');

			for (var i = 0; i < box.length; i++) {

				box[i].axbs = i;

				box[i].onclick = function () {
					
					alert(this.axbs);
				}
			}

			console.log(box);

			// function add_click(k) {
			// 	box[k].onclick = function () {
			// 		alert(k);
			// 	}
			// }
		}


	</script>
</head>
<body>
	<ul>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
		<li class="box">1</li>
		<li class="box">2</li>
		<li class="box">3</li>
	</ul>
</body>
</html>